﻿@model WebUI.Areas.Bots.Models.Operations
@{
    Layout = MVC.Bots.Shared.Views._Main;
}
@section Title{@WebUI.Resources.Operations}
@section PageName{@WebUI.Resources.Operations}
<script type="text/javascript" language="javascript">
    $(document).ready(function () {
        ToggleDivs();
    });

    function ToggleDivs() {
        if ($('#IsAllOperations').is(':checked')) {
            $('#AllOperationsDiv :input').attr('disabled', true);
            UnCheckAll();
        } else {
            $('#AllOperationsDiv :input').removeAttr('disabled');
        }
    }

    function UnCheckAll() {
        var checkboxes = document.forms[0].getElementsByTagName('input');

        for (var i = 0; i < checkboxes.length; i++) {
            if (checkboxes[i].type == 'checkbox') {
                checkboxes[i].checked = false;
            }
        }
    }
</script>
@using (Html.BeginForm(MVC.Bots.Operations.Save()))
{
    @Html.ValidationSummary(false)
    <div class="filter_bar">
        <h3>
            Operations</h3>
        @Html.RadioButtonFor(model => model.IsAllOperations, true, new { @Id = "IsAllOperations", @onchange = "ToggleDivs();" })
        <span>All Operations</span>
        @Html.RadioButtonFor(model => model.IsAllOperations, false, new { @onchange = "ToggleDivs();" })<span>Specific
            Operations</span>
        <div id="AllOperationsDiv">
            @Html.CheckBoxList("selectedOperations",
                   x => x.AllOperations,
                   x => x.OperationID,
                   x => x.OperationName,
                   x => x.SelectedOperations,
                   Position.Vertical)
        </div>
    </div>
    @Html.ActionLink(WebUI.Resources.Previous, MVC.Bots.BotFilters.Index(), new { @class = "prev btn" })
    <input type="submit" class="next btn" value='@WebUI.Resources.Next' />
}
